<?php

class setting_model extends CI_Model {

    function __construct()
    {
        parent::__construct();
        
    }
    function get($ID=""){
        $where=array("ID"=>$ID);
        $query=$this->db->get_where('adp_settings', $where); 
        return $query->result();
    }
    function getByKey($Key=""){
        $where=array("Key"=>$Key);
        $query=$this->db->get_where('adp_settings', $where); 
        return $query->result();
    }
    function gets(){
        return  $this->db
                ->get('adp_settings')
                ->result();
    }
    function insert($Params){
        $this->db->insert('adp_settings', $Params); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return true;
        return false;
    }
    function update($ID,$Params){
        $this->db->set('Update', "NOW()",false);
        $this->db->where('ID', $ID);
        $this->db->update('adp_settings', $Params); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return true;
        return false;
    }
    function updateByKey($Key,$Params){
        $this->db->set('Update', "NOW()",false);
        $this->db->where('Key', $Key);
        $this->db->update('adp_settings', $Params); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return true;
        return false;
    }
    function insert_onduplicate_update($aParamsi,$aUpdate){
        $this->db->on_duplicate_update('adp_settings', $aUpdate, $aParamsi); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count>0) return true;
        return false;
    }
    function delete($ID){
        $this->db->set('Description', "NOW()",false);
        $this->db->where('ID', $ID);
        $this->db->update('adp_settings'); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return true;
        return false;
    }
    
}
?>
